package com.meirengu.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.meirengu.model.MQMessage;

import java.util.ArrayList;
import java.util.List;

public class MQMessageUtil {

    public MQMessageUtil() {
        super();
    }

    /**
     * @param json
     * @return
     */
    public static List<MQMessage> toList(String json) {
        List<MQMessage> messages = new ArrayList<MQMessage>();
        JSONArray j = JSONArray.parseArray(json);

        for (int i = 0; i < j.size(); i++) {
            MQMessage jb = JSON.parseObject(j.get(i).toString(), MQMessage.class);
            messages.add(jb);
        }
        return messages;
    }
}
